package com.odontosis.view;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ajaxtags.servlets.BaseAjaxServlet;
import org.ajaxtags.xml.AjaxXmlBuilder;

import com.odontosis.entidade.Paciente;
import com.odontosis.ioc.ContainerIoc;
import com.odontosis.service.PacienteService;

public class AutoCompletePolicia extends BaseAjaxServlet {

	  /**
	   * @see BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest,
	   *      javax.servlet.http.HttpServletResponse)
	   */
	  public String getXmlContent(HttpServletRequest request, HttpServletResponse response)
	      throws Exception {
	    String model = request.getParameter("model");
	    PacienteService service = ContainerIoc.getPacienteService();
	    List<Paciente> list = service.pesquisarParaAutoCompleteComIpsm(model);
	    
	    

	    // Create xml schema
	    String retorno ="";
	    try{
	    	 retorno = new AjaxXmlBuilder().addItems(list, "descricaoAutoComplete", "id",true).toString();
	    }catch (Exception e) {
	    	e.printStackTrace();
		}
	    return retorno;
	  }


}
